﻿package mortal.game.view.forging.view
{
    import Message.DB.Tables.*;
    import Message.Game.*;
    import com.greensock.layout.*;
    import com.mui.controls.*;
    import com.mui.core.*;
    import com.mui.display.*;
    import com.mui.utils.*;
    import extend.language.*;
    import fl.data.*;
    import flash.display.*;
    import flash.events.*;
    import flash.utils.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.component.gconst.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.common.util.*;
    import mortal.game.view.forging.data.*;
    import mortal.game.view.forging.renderer.*;
    import mortal.game.view.forging.util.*;
    import mortal.game.view.palyer.*;
    import mortal.game.view.systemSetting.*;
    import mortal.mvc.core.*;

    public class EquipRefreshPanel extends ForgingPanelBase
    {
        private var _currPropList:GTileList;
        private var _newPropList:GTileList;
        private var _refreshBtn:GButton;
        private var _replaceBtn:GButton;
        private var _batRefreshBtn:GButton;
        private var _autoBuy:GCheckBox;
        private var _equipDescText:GTextFiled;
        private var _spr:Sprite;
        private var _txtEquipCombat:BitmapNumberText;
        private var _txtEquipCombatNew:BitmapNumberText;
        private var _combatUpValue:GTextFiled;
        private var _consumeItem1:BaseItem;
        private var _consumeItem2:BaseItem;
        private var _upFee:GTextFiled;
        private var _putEquipImg:GImageBitmap;
        private var _upArrow:GBitmap;
        private var _reviewText1:GTextFiled;
        private var _reviewText2:GTextFiled;
        private var _bestViewEquip:PlayerEquipItem;
        private var _hotInfo:GTextFiled;
        private var _batRefreshPanel:BatRefreshPanel;
        private var _batRefreshData:Array;
        private var _lockNum:int;
        private var _attrBgArr:Array;
        private var _isPropEnough:Boolean;
        private var _isLockEnough:Boolean;

        public function EquipRefreshPanel(param1:Window)
        {
            this._batRefreshData = new Array();
            this._attrBgArr = new Array();
            super(param1);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.createChildren();
            return;
        }// end function

        private function onResLoadCompl(param1 = null) : void
        {
            if (isDisposed)
            {
                return;
            }
            this.createChildren();
            return;
        }// end function

        override protected function createChildren() : void
        {
            var _loc_5:int = 0;
            var _loc_6:int = 0;
            var _loc_7:ScaleBitmap = null;
            super.createChildren();
            this._bestViewEquip = UICompomentPool.getUICompoment(PlayerEquipItem);
            this._bestViewEquip.setItemStyle(ItemStyleConst.Small, ImagesConst.EquipItemBg, 5, 5);
            this._bestViewEquip.x = 12;
            this._bestViewEquip.y = 10;
            this.addChild(this._bestViewEquip);
            this._bestViewEquip.isShowArroundEffect = false;
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.Forging_StrengBestPreview, 6, 55, this));
            this.pushUIToDisposeVec(UIFactory.gBitmap(ImagesConst.TextBg3, 157 - 25, 1, this));
            var _loc_1:* = GlobalStyle.textFormatBai;
            _loc_1.align = AlignMode.CENTER;
            this._equipDescText = UIFactory.gTextField("", 128, 7, 234, 20, this, _loc_1);
            this._equipDescText.htmlText = Language.getString(40102);
            _currOperEquip = UICompomentPool.getUICompoment(PlayerEquipItem);
            _currOperEquip.setItemStyle(ItemStyleConst.Big, "", 0, 0);
            _currOperEquip.x = 213 + 7;
            _currOperEquip.y = 74 + 7;
            this.addChild(_currOperEquip);
            _currOperEquip.isShowArroundEffect = false;
            this._hotInfo = UIFactory.gTextField("", 0, 170 - 2, 493, 20, this, GlobalStyle.textFormatDanLan.center());
            this._putEquipImg = UIFactory.gImageBitmap(ImagesConst.Forging_PutInEquip, 225 + 3, 81 + 9, this);
            var _loc_2:* = GlobalStyle.textFormatLv;
            _loc_2.size = 14;
            var _loc_3:* = GlobalStyle.textFormatChen;
            _loc_3.size = 14;
            this._txtEquipCombat = UIFactory.bitmapNumberText(104 + 27 + 2, 214, "FightInfoNum.png", 12, 15, -1, this);
            this._txtEquipCombat.text = "";
            this._reviewText1 = UIFactory.gTextField("？ ？ ？", 108 + 20, 211, 48, 20, this);
            this._txtEquipCombatNew = UIFactory.bitmapNumberText(373 + 27 - 8, 214, "FightInfoNum.png", 12, 15, -1, this);
            this._txtEquipCombatNew.text = "";
            this._reviewText2 = UIFactory.gTextField("？ ？ ？", 378 + 10, 211, 100, 20, this);
            this._upArrow = UIFactory.gBitmap(ImagesConst.upgradeArrow, 421 + 8, 214, this);
            this._upArrow.visible = false;
            this._combatUpValue = UIFactory.gTextField("", 436 + 4, 211, 40, 20, this, GlobalStyle.textFormatLv);
            var _loc_4:int = 0;
            while (_loc_4 < 12)
            {
                
                _loc_5 = _loc_4 < 6 ? (25) : (298 - 13);
                _loc_6 = 221 + 18 + 19 * (_loc_4 % 6);
                _loc_7 = UIFactory.bg(_loc_5, _loc_6, 170, 19, this, ImagesConst.RefreshAttrBg);
                this.pushUIToDisposeVec(_loc_7);
                this._attrBgArr.push(_loc_7);
                _loc_4++;
            }
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(41119), 82 - 2, 368 - 4, 65, 20, this));
            this._consumeItem1 = UICompomentPool.getUICompoment(BaseItem);
            this._consumeItem1.setItemStyle(ItemStyleConst.Small, ImagesConst.PackItemBg, 2, 2);
            this._consumeItem1.x = 226 - 154 + 14;
            this._consumeItem1.y = 205 - 9 + 178 + 10;
            this.addChild(this._consumeItem1);
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(41120), 376 - 2, 368 - 4, 65, 20, this));
            this._consumeItem2 = UICompomentPool.getUICompoment(BaseItem);
            this._consumeItem2.setItemStyle(ItemStyleConst.Small, ImagesConst.PackItemBg, 2, 2);
            this._consumeItem2.x = 380;
            this._consumeItem2.y = 205 - 9 + 178 + 10;
            this.addChild(this._consumeItem2);
            this._spr = UIFactory.sprite(0, 0, this);
            this._currPropList = UIFactory.tileList(25 - 5, 220 + 18, 170 + 30, 126, this._spr);
            this._currPropList.columnWidth = 168 + 30;
            this._currPropList.rowHeight = 19;
            this._currPropList.horizontalGap = 0;
            this._currPropList.verticalGap = 0;
            this._currPropList.setStyle("skin", new Bitmap());
            this._currPropList.setStyle("cellRenderer", RefreshPropCellRenderer);
            this._currPropList.configEventListener(MouseEvent.CLICK, this.onLockClickHandler);
            this._newPropList = UIFactory.tileList(298 - 13 - 5, 220 + 18, 170 + 30, 126, this._spr);
            this._newPropList.columnWidth = 168 + 30;
            this._newPropList.rowHeight = 19;
            this._newPropList.horizontalGap = 0;
            this._newPropList.verticalGap = 0;
            this._newPropList.setStyle("skin", new Bitmap());
            this._newPropList.setStyle("cellRenderer", RefreshPropCellRenderer);
            this._refreshBtn = UIFactory.gButton(Language.getString(41121), 107 + 48, 372, 84, 27, this, "BrownBtn");
            this._refreshBtn.mouseChildren = false;
            this._refreshBtn.name = "ForgingModule_RefreshBtn";
            this._refreshBtn.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            this._replaceBtn = UIFactory.gButton(Language.getString(41122), 204 + 48, 372, 84, 27, this, "BrownBtn");
            this._replaceBtn.mouseChildren = false;
            this._replaceBtn.name = "ForgingModule_replaceBtn";
            this._replaceBtn.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            this._batRefreshBtn = UIFactory.gButton(Language.getString(41123), 301, 372, 84, 27, this, "BrownBtn");
            this._batRefreshBtn.mouseChildren = false;
            this._batRefreshBtn.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            this._batRefreshBtn.visible = false;
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(41124), 146, 409, 86, 20, this, GlobalStyle.textFormatHuang));
            this._upFee = UIFactory.gTextField("", 207, 409, 35, 20, this, GlobalStyle.textFormatHuang);
            this.pushUIToDisposeVec(UIFactory.gBitmap(ImagesConst.Jinbi_bind, 239, 409, this));
            this._autoBuy = UIFactory.checkBox(Language.getString(41125), 285, 406, 140, 28, this);
            this._autoBuy.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            this._batRefreshPanel = UICompomentPool.getUICompoment(BatRefreshPanel);
            _currOperEquip.configEventListener(MouseEvent.CLICK, onEquipClickHandler);
            Dispatcher.addEventListener(EventName.SynchRefreshLock, this.syncLockState);
            this.initAutoBuyState();
            return;
        }// end function

        private function initAutoBuyState() : void
        {
            if (ClientSetting.local.getIsDone(IsDoneType.AutoBuyRefreshProp))
            {
                this._autoBuy.selected = true;
            }
            else
            {
                this._autoBuy.selected = false;
            }
            return;
        }// end function

        override public function updateUI() : void
        {
            return;
        }// end function

        private function onClickHandler(event:MouseEvent) : void
        {
            var obj:Object;
            var operType:EOperType;
            var priority:EPriorityType;
            var lockDic:Dictionary;
            var lockNum:int;
            var i:int;
            var equipLevel:int;
            var maxAttrNum:int;
            var propData:RefreshPropVO;
            var e:* = event;
            if (!_currOperEquip.itemData)
            {
                MsgManager.showRollTipsMsg(Language.getString(41126));
                return;
            }
            if (e.target == this._refreshBtn)
            {
                obj;
                operType = new EOperType(EOperType._EOperTypeSimple);
                priority = new EPriorityType(EPriorityType._EProiorityTypeBindFirst);
                lockDic = new Dictionary();
                i;
                while (i < this._currPropList.length)
                {
                    
                    propData = this._currPropList.getItemAt(i) as RefreshPropVO;
                    if (propData.isLock)
                    {
                        lockDic[propData.pos] = 1;
                        lockNum = (lockNum + 1);
                    }
                    i = (i + 1);
                }
                equipLevel = _currOperEquip.itemData.itemInfo.level;
                maxAttrNum = EquipRefreshConfig.instance.getMaxAttrNum(equipLevel);
                if (lockNum == maxAttrNum)
                {
                    MsgManager.showRollTipsMsg(Language.getString(41127));
                    return;
                }
                obj.equipUid = _currOperEquip.itemData.uid;
                obj.type = operType;
                obj.priority = priority;
                obj.lockDict = lockDic;
                obj.expectAttr = new Dictionary();
                obj.expectAttrAll = 0;
                if (ClientSetting.local.getIsDone(IsDoneType.AutoBuyRefreshProp))
                {
                    obj.autoBuyRefreshTone = true;
                    obj.autoBuyLockMaterial = true;
                }
                else
                {
                    obj.autoBuyRefreshTone = false;
                    obj.autoBuyLockMaterial = false;
                }
                if (!this._batRefreshPanel.isHide)
                {
                    if (this._batRefreshPanel.isGetExpectAttr)
                    {
                        var onClickHandler:* = function (param1:int) : void
            {
                if (param1 == Alert.OK)
                {
                    onSingleRefresh(obj);
                }
                else
                {
                    return;
                }
                return;
            }// end function
            ;
                        Alert.show(Language.getString(41128), null, Alert.OK | Alert.CANCEL, null, onClickHandler);
                    }
                    else
                    {
                        this.onSingleRefresh(obj);
                    }
                }
                else
                {
                    this.onSingleRefresh(obj);
                }
            }
            if (e.target == this._replaceBtn)
            {
                obj;
                obj.equipUid = _currOperEquip.itemData.uid;
                obj.replaceIndex = 1;
                Dispatcher.dispatchEvent(new DataEvent(EventName.EquipRefreshReplace, obj));
            }
            if (e.target == this._batRefreshBtn)
            {
                if (this._batRefreshPanel.isHide)
                {
                    this._batRefreshPanel.show();
                    this._batRefreshPanel.currWashEquip = _currOperEquip;
                    this._batRefreshPanel.updateExpectProp();
                    this._batRefreshPanel.updateCurrInfo(this._currPropList.dataProvider);
                    this._batRefreshPanel.updateNewInfo(this._batRefreshData);
                    this.updateReviewCombat();
                    this.updateBatRefreshSync();
                }
            }
            if (e.target == this._autoBuy)
            {
                if (this._autoBuy.selected == true)
                {
                    ClientSetting.local.setIsDone(true, IsDoneType.AutoBuyRefreshProp);
                }
                else
                {
                    ClientSetting.local.setIsDone(false, IsDoneType.AutoBuyRefreshProp);
                }
            }
            return;
        }// end function

        private function onSingleRefresh(param1:Object) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.EquipRefresh, param1));
            return;
        }// end function

        private function onLockClickHandler(event:MouseEvent) : void
        {
            var _loc_2:RefreshPropCellRenderer = null;
            var _loc_3:RefreshPropVO = null;
            if (event.target is Sprite)
            {
                _loc_2 = this._currPropList.itemToCellRenderer(this._currPropList.selectedItem) as RefreshPropCellRenderer;
                _loc_3 = this._currPropList.selectedItem as RefreshPropVO;
                _loc_3.isLock = !_loc_3.isLock;
                _loc_2.data = _loc_3;
                _loc_2.drawNow();
                this._currPropList.sortItems(this.sortOnLockState);
                if (_loc_3.isLock)
                {
                    this.updateLockNum(1);
                }
                else
                {
                    this.updateLockNum(2);
                }
                this.updateItemLockNum();
                if (!this._batRefreshPanel.isHide)
                {
                    this._batRefreshPanel.updateCurrInfo(this._currPropList.dataProvider);
                    this._batRefreshPanel.updateConsumeItem();
                }
            }
            return;
        }// end function

        private function syncLockState(event:DataEvent) : void
        {
            var _loc_2:* = event.data as Dictionary;
            this._currPropList.dataProvider = _loc_2["dataProvider"];
            this._currPropList.sortItems(this.sortOnLockState);
            this._currPropList.drawNow();
            if (_loc_2["isLock"])
            {
                this.updateLockNum(1);
            }
            else
            {
                this.updateLockNum(2);
            }
            this.updateConsumeItem();
            this._batRefreshPanel.updateConsumeItem();
            return;
        }// end function

        private function sortOnLockState(param1:RefreshPropVO, param2:RefreshPropVO) : int
        {
            if (param1.isLock && !param2.isLock)
            {
                return -1;
            }
            if (!param1.isLock && param2.isLock)
            {
                return 1;
            }
            return this.sortOnPosition(param1, param2);
        }// end function

        private function sortOnPosition(param1:RefreshPropVO, param2:RefreshPropVO) : int
        {
            if (param1.pos < param2.pos)
            {
                return -1;
            }
            return 1;
        }// end function

        override public function addForgingEquip(param1:PlayerEquipItem) : void
        {
            var _loc_2:Boolean = false;
            if (param1 && param1.itemData)
            {
                if (!_currOperEquip.itemData || _currOperEquip.itemData.uid != param1.itemData.uid)
                {
                    _loc_2 = true;
                }
                _currOperEquip.itemData = param1.itemData;
                _currOperEquip.updateStrengLevel();
                this.updateRefreshInfo();
                if (!this._batRefreshPanel.isHide)
                {
                    this._batRefreshPanel.currWashEquip = param1;
                }
                this.updateEquipDesc();
                this.updateHotInfo();
                this.resetLockNum();
                this.updateLockNum();
                this.updateConsumeMoney();
                this.updateConsumeItem();
                this.updateBestEquip();
                if (this._putEquipImg.visible)
                {
                    this._putEquipImg.visible = false;
                }
                if (this._reviewText1.visible)
                {
                    this._reviewText1.visible = false;
                }
                if (this._reviewText2.visible)
                {
                    this._reviewText2.visible = false;
                }
                if (!this._batRefreshPanel.isHide)
                {
                    if (_loc_2)
                    {
                        this._batRefreshPanel.updateExpectProp();
                    }
                    if (!EquipmentUtil.isRefreshed(_currOperEquip.itemData))
                    {
                        return;
                    }
                    this.updateBatRefreshSync();
                }
            }
            return;
        }// end function

        override public function updateForgingInfo() : void
        {
            this.updateRefreshInfo();
            this.updateItemLockNum();
            if (!this._batRefreshPanel.isHide)
            {
                if (!EquipmentUtil.isRefreshed(_currOperEquip.itemData))
                {
                    return;
                }
                this._batRefreshPanel.updateCombat();
            }
            if (Cache.instance.forging.refreshCallBackFlag == ForgingConst.RefreshFlag_Refresh)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.ForgingPlayRefreshEffect));
            }
            else
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.ForgingPlayReplaceEffect));
            }
            return;
        }// end function

        public function updateBatRefreshSync() : void
        {
            this._batRefreshPanel.updateCombat();
            this._batRefreshPanel.updateEquipDesc();
            this._batRefreshPanel.updateConsumeItem();
            return;
        }// end function

        private function updateBestEquip() : void
        {
            var _loc_7:int = 0;
            var _loc_1:* = new ItemData(_currOperEquip.itemData.itemCode, true);
            var _loc_2:* = _currOperEquip.itemData.extInfo.clone();
            var _loc_3:* = EquipmentUtil.getCategoryByEquipType(_currOperEquip.itemData.itemInfo.type);
            var _loc_4:* = _currOperEquip.itemData.itemInfo.level;
            var _loc_5:* = _currOperEquip.itemData.itemInfo.type;
            var _loc_6:* = EquipRefreshConfig.instance.getMaxStarLevel(_loc_4);
            var _loc_8:* = ForgingUtil.instance.getLevelRange(_currOperEquip.itemData.itemInfo.level);
            var _loc_9:* = EquipRefreshConfig.instance.getMaxAttrNum(_loc_4);
            var _loc_10:* = StrengUtil.getEquipHotAttrType(_loc_5);
            var _loc_11:int = 1;
            while (_loc_11 <= _loc_9)
            {
                
                _loc_2["addition" + _loc_11] = _loc_10;
                _loc_2["addStar" + _loc_11] = _loc_6;
                _loc_11++;
            }
            _loc_1.extInfo = _loc_2;
            this._bestViewEquip.itemData = _loc_1;
            this._bestViewEquip.updateStrengLevel();
            _loc_1.extInfo.combat = EquipmentUtil.getEquipCombat(_loc_1);
            _loc_1.extData = _loc_1.extInfo;
            _loc_1.extDataType = ItemDataExtDataType.Type_XiLianYuLan;
            return;
        }// end function

        private function updateEquipDesc() : void
        {
            this._equipDescText.htmlText = ItemsUtil.getItemWholeName(_currOperEquip.itemData, true, 1, false);
            return;
        }// end function

        private function updateHotInfo() : void
        {
            var _loc_3:int = 0;
            var _loc_4:String = null;
            var _loc_5:int = 0;
            var _loc_1:* = GameDefConfig.instance.getEquipName(_currOperEquip.itemData.itemInfo.type);
            var _loc_2:* = EquipJewelMatchConfig.instance.getInfoByType(_currOperEquip.itemData.itemInfo.type, "refresh");
            if (_loc_2)
            {
                _loc_3 = _loc_2.jeweltype;
                _loc_4 = GameDefConfig.instance.getItem("FightRoleAttribute", _loc_3).text1;
                _loc_5 = 50;
                this._hotInfo.htmlText = Language.getStringByParam(41129, _loc_1, _loc_4, _loc_5);
            }
            return;
        }// end function

        private function updateEquipCombat() : void
        {
            this._txtEquipCombat.text = "" + StrengUtil.getRefreshCombat(_currOperEquip.itemData);
            if (!this._batRefreshPanel.isHide)
            {
                this._batRefreshPanel.updateCombat();
            }
            return;
        }// end function

        private function updateReviewCombat() : void
        {
            var _loc_5:Array = null;
            var _loc_6:int = 0;
            var _loc_7:int = 0;
            var _loc_8:Array = null;
            var _loc_1:* = new ItemData(_currOperEquip.itemData.itemCode, true);
            _loc_1.extInfo = _currOperEquip.itemData.extInfo.clone();
            var _loc_2:* = _currOperEquip.itemData.extInfo.refresh_refDict;
            var _loc_3:Array = [];
            var _loc_4:int = 1;
            for each (_loc_5 in _loc_2)
            {
                
                _loc_4 = 1;
                for each (_loc_8 in _loc_5)
                {
                    
                    _loc_1.extInfo["addition" + _loc_4] = _loc_8[0];
                    _loc_1.extInfo["addStar" + _loc_4] = _loc_8[1];
                    _loc_4++;
                }
                _loc_3.push(StrengUtil.getRefreshCombat(_loc_1));
            }
            _loc_6 = StrengUtil.getRefreshCombat(_currOperEquip.itemData);
            _loc_7 = _loc_3[0] - _loc_6;
            this._txtEquipCombatNew.text = "" + _loc_3[0];
            this._combatUpValue.text = "" + Math.abs(_loc_7);
            if (!this._upArrow.visible)
            {
                this._upArrow.visible = true;
            }
            if (_loc_7 > 0)
            {
                this._upArrow.bitmapData = GlobalClass.getBitmapData(ImagesConst.upgradeArrow);
            }
            else if (_loc_7 < 0)
            {
                this._upArrow.bitmapData = GlobalClass.getBitmapData(ImagesConst.downArrow);
            }
            else
            {
                this._upArrow.bitmapData = null;
                this._combatUpValue.text = "";
            }
            this._upArrow.x = this._txtEquipCombatNew.x + this._txtEquipCombatNew.width + 2;
            this._combatUpValue.x = this._txtEquipCombatNew.x + this._txtEquipCombatNew.width + 2 + 12;
            if (!this._batRefreshPanel.isHide)
            {
                this._batRefreshPanel.updateAllNewCombat(_loc_3);
            }
            return;
        }// end function

        private function updateLockNum(param1:int = 0) : void
        {
            var _loc_2:String = null;
            var _loc_3:Array = null;
            if (param1 == 0)
            {
                _loc_2 = _currOperEquip.itemData.extInfo.refresh_lock;
                if (_loc_2)
                {
                    _loc_3 = _loc_2.split(",");
                    if (_loc_3)
                    {
                        this._lockNum = _loc_3.length - 1;
                    }
                }
            }
            if (param1 == 1)
            {
                var _loc_4:String = this;
                var _loc_5:* = this._lockNum + 1;
                _loc_4._lockNum = _loc_5;
            }
            if (param1 == 2)
            {
                var _loc_4:String = this;
                var _loc_5:* = this._lockNum - 1;
                _loc_4._lockNum = _loc_5;
            }
            this._batRefreshPanel.lockNum = this._lockNum;
            return;
        }// end function

        private function resetLockNum() : void
        {
            this._lockNum = 0;
            return;
        }// end function

        private function updateConsumeMoney() : void
        {
            var _loc_1:int = 0;
            var _loc_2:int = 0;
            var _loc_3:int = 0;
            if (_currOperEquip.itemData)
            {
                _loc_1 = _currOperEquip.itemData.itemInfo.level;
                _loc_2 = ForgingUtil.instance.getLevelRange(_currOperEquip.itemData.itemInfo.level);
                _loc_3 = EquipRefreshConfig.instance.getConsumeMoney(_loc_1);
                this._upFee.text = _loc_3 + "";
                if (_loc_3 > Cache.instance.role.money.coin + Cache.instance.role.money.coinBind)
                {
                    this._upFee.textColor = GlobalStyle.colorHongUint;
                }
                else
                {
                    this._upFee.textColor = GlobalStyle.colorHuangUint;
                }
            }
            return;
        }// end function

        private function updateConsumeItem() : void
        {
            var _loc_4:ItemData = null;
            var _loc_6:ItemData = null;
            var _loc_7:int = 0;
            var _loc_1:* = _currOperEquip.itemData.itemInfo.level;
            var _loc_2:* = ForgingUtil.instance.getLevelRange(_currOperEquip.itemData.itemInfo.level);
            var _loc_3:* = EquipRefreshConfig.instance.getConsumeItem(_loc_1);
            if (_loc_3 != 0)
            {
                _loc_6 = new ItemData(_loc_3);
                _loc_7 = _loc_6.itemInfo.codeUnbind;
                _loc_4 = new ItemData(_loc_7);
            }
            var _loc_5:* = new ItemData(410040000);
            this._consumeItem1.itemData = _loc_4;
            if (this._lockNum == 0)
            {
                this._consumeItem2.itemData = null;
            }
            else
            {
                this._consumeItem2.itemData = _loc_5;
                this._consumeItem2.amount = this._lockNum;
            }
            this.updateConsumeState();
            return;
        }// end function

        override public function updateConsumeState() : void
        {
            var _loc_1:int = 0;
            var _loc_2:int = 0;
            var _loc_3:int = 0;
            var _loc_4:int = 0;
            var _loc_5:int = 0;
            if (this._consumeItem1.itemData)
            {
                _loc_1 = this._consumeItem1.itemData.itemInfo.type;
                _loc_2 = Cache.instance.pack.backPackCache.getItemCountByItemData(this._consumeItem1.itemData);
                _loc_3 = 1;
                if (_loc_3 <= _loc_2)
                {
                    this._consumeItem1.isGray = false;
                    this._isPropEnough = true;
                }
                else
                {
                    this._consumeItem1.isGray = true;
                    this._isPropEnough = false;
                }
            }
            if (this._consumeItem2.itemData)
            {
                _loc_4 = Cache.instance.pack.backPackCache.getItemCountByItemData(this._consumeItem2.itemData);
                _loc_5 = this._lockNum;
                if (_loc_5 <= _loc_4)
                {
                    this._consumeItem2.isGray = false;
                    this._isLockEnough = true;
                }
                else
                {
                    this._consumeItem2.isGray = true;
                    this._isLockEnough = false;
                }
            }
            else
            {
                this._isLockEnough = true;
            }
            return;
        }// end function

        private function updateItemLockNum() : void
        {
            var _loc_2:int = 0;
            var _loc_3:int = 0;
            var _loc_1:* = new ItemData(410040000);
            if (this._lockNum > 0)
            {
                this._consumeItem2.itemData = _loc_1;
                this._consumeItem2.amount = this._lockNum;
                _loc_2 = Cache.instance.pack.backPackCache.getItemCountByItemData(this._consumeItem2.itemData);
                _loc_3 = this._lockNum;
                if (_loc_3 <= _loc_2)
                {
                    this._consumeItem2.isGray = false;
                }
                else
                {
                    this._consumeItem2.isGray = true;
                }
            }
            else
            {
                this._consumeItem2.itemData = null;
            }
            return;
        }// end function

        override public function updateMoneyState() : void
        {
            this.updateConsumeMoney();
            return;
        }// end function

        public function updateRefreshInfo() : void
        {
            if (_currOperEquip && _currOperEquip.itemData)
            {
                if (EquipmentUtil.isRefreshed(_currOperEquip.itemData))
                {
                    this.isReplacable = true;
                    this.updateCurrInfo();
                    this.updateNewInfo();
                }
                else
                {
                    this.clearRefreshInfo();
                    if (!this._batRefreshPanel.isHide)
                    {
                        this._batRefreshPanel.clearUI();
                    }
                    this.isReplacable = false;
                    this.clearReviewCombat();
                }
                this.updateEquipCombat();
            }
            return;
        }// end function

        public function updateCurrInfo() : void
        {
            var _loc_7:int = 0;
            var _loc_9:RefreshPropVO = null;
            var _loc_10:String = null;
            var _loc_11:int = 0;
            var _loc_1:* = new DataProvider();
            var _loc_2:* = _currOperEquip.itemData.extInfo;
            var _loc_3:* = _loc_2.refresh_lock == null ? ([]) : (_loc_2.refresh_lock.split(","));
            var _loc_4:* = _currOperEquip.itemData.itemInfo.level;
            var _loc_5:* = _currOperEquip.itemData.itemInfo.type;
            var _loc_6:* = EquipRefreshConfig.instance.getMaxStarLevel(_loc_4);
            var _loc_8:int = 1;
            while (_loc_8 <= 6)
            {
                
                if (_loc_2["addStar" + _loc_8] != 0 && _loc_2["addStar" + _loc_8] != -1)
                {
                    _loc_9 = new RefreshPropVO();
                    _loc_10 = ForgingUtil.instance.getAttrNameByType(_loc_2["addition" + _loc_8]);
                    _loc_11 = ForgingUtil.instance.getAddtionValue(_loc_2["addition" + _loc_8], _loc_2["addStar" + _loc_8]);
                    _loc_9.pos = _loc_8;
                    _loc_9.attrType = _loc_2["addition" + _loc_8];
                    _loc_9.attrValue = _loc_11;
                    if (_loc_9.attrType == StrengUtil.getEquipHotAttrType(_loc_5))
                    {
                        _loc_9.hotAddValue = _loc_11 / 2;
                    }
                    _loc_9.attrStar = _loc_2["addStar" + _loc_8];
                    _loc_9.attrName = _loc_10;
                    _loc_9.color = ForgingUtil.instance.getPropColor(_loc_2["addStar" + _loc_8], _loc_6);
                    _loc_9.isOwnAttr = true;
                    if (_loc_3.indexOf(_loc_8 + "") != -1)
                    {
                        _loc_9.isLock = true;
                        _loc_7++;
                    }
                    else
                    {
                        _loc_9.isLock = false;
                    }
                    _loc_1.addItem(_loc_9);
                }
                _loc_8++;
            }
            this._currPropList.dataProvider = _loc_1;
            this._currPropList.sortItems(this.sortOnLockState);
            this._currPropList.drawNow();
            this._lockNum = _loc_7;
            if (!this._batRefreshPanel.isHide)
            {
                this._batRefreshPanel.updateCurrInfo(_loc_1);
            }
            this.updateAttrBg(1);
            return;
        }// end function

        private function updateAttrBg(param1:int) : void
        {
            var _loc_2:int = 0;
            var _loc_3:Array = null;
            var _loc_4:int = 0;
            var _loc_5:Array = null;
            if (param1 == 1)
            {
                _loc_2 = this._currPropList.length;
                _loc_3 = this._attrBgArr.slice(0, 6);
                _loc_4 = 0;
                while (_loc_4 < _loc_3.length)
                {
                    
                    if (_loc_4 < _loc_2)
                    {
                        _loc_3[_loc_4].visible = true;
                    }
                    else
                    {
                        _loc_3[_loc_4].visible = false;
                    }
                    _loc_4++;
                }
            }
            if (param1 == 2)
            {
                _loc_2 = this._newPropList.length;
                _loc_5 = this._attrBgArr.slice(6);
                _loc_4 = 0;
                while (_loc_4 < _loc_5.length)
                {
                    
                    if (_loc_4 < _loc_2)
                    {
                        _loc_5[_loc_4].visible = true;
                    }
                    else
                    {
                        _loc_5[_loc_4].visible = false;
                    }
                    _loc_4++;
                }
            }
            return;
        }// end function

        public function updateNewInfo() : void
        {
            var _loc_7:Array = null;
            var _loc_8:int = 0;
            var _loc_9:Array = null;
            var _loc_10:Array = null;
            var _loc_11:RefreshPropVO = null;
            var _loc_12:String = null;
            var _loc_13:int = 0;
            var _loc_14:RefreshPropCellRenderer = null;
            var _loc_1:* = new DataProvider();
            var _loc_2:* = _currOperEquip.itemData.extInfo;
            var _loc_3:* = _loc_2.refresh_lock == null ? ([]) : (_loc_2.refresh_lock.split(","));
            var _loc_4:* = _currOperEquip.itemData.itemInfo.level;
            var _loc_5:* = _currOperEquip.itemData.itemInfo.type;
            var _loc_6:* = EquipRefreshConfig.instance.getMaxStarLevel(_loc_4);
            if (!_loc_2.refresh_refDict || _loc_2.refresh_refDict.length == 0)
            {
                this._newPropList.dataProvider = _loc_1;
                this._newPropList.drawNow();
                this.isReplacable = false;
                this._batRefreshData = [];
                this.clearReviewCombat();
            }
            else
            {
                _loc_7 = [];
                _loc_8 = _loc_3.length - 1;
                for each (_loc_9 in _loc_2.refresh_refDict)
                {
                    
                    _loc_8 = _loc_3.length - 1;
                    _loc_1 = new DataProvider();
                    for each (_loc_10 in _loc_9)
                    {
                        
                        if (_loc_10[0] != -1 && _loc_10[1] != -1)
                        {
                            _loc_11 = new RefreshPropVO();
                            _loc_12 = ForgingUtil.instance.getAttrNameByType(_loc_10[0]);
                            _loc_13 = ForgingUtil.instance.getAddtionValue(_loc_10[0], _loc_10[1]);
                            _loc_11.attrType = _loc_10[0];
                            _loc_11.attrValue = _loc_13;
                            if (_loc_11.attrType == StrengUtil.getEquipHotAttrType(_loc_5))
                            {
                                _loc_11.hotAddValue = _loc_13 / 2;
                            }
                            _loc_11.attrStar = _loc_10[1];
                            _loc_11.attrName = _loc_12;
                            _loc_11.color = ForgingUtil.instance.getPropColor(_loc_10[1], _loc_6);
                            _loc_11.isOwnAttr = false;
                            if (_loc_8 > 0)
                            {
                                _loc_11.isLock = true;
                            }
                            else
                            {
                                _loc_11.isLock = false;
                            }
                            _loc_1.addItem(_loc_11);
                        }
                        _loc_8 = _loc_8 - 1;
                    }
                    _loc_7.push(_loc_1);
                }
                this._newPropList.dataProvider = _loc_7[0];
                this._newPropList.drawNow();
                _loc_8 = 0;
                while (_loc_8 < this._newPropList.length)
                {
                    
                    _loc_14 = this._newPropList.itemToCellRenderer(this._newPropList.getItemAt(_loc_8)) as RefreshPropCellRenderer;
                    _loc_14.setLockDisabled();
                    _loc_8++;
                }
                this._batRefreshData = _loc_7;
            }
            if (!this._batRefreshPanel.isHide)
            {
                this._batRefreshPanel.updateNewInfo(this._batRefreshData);
            }
            this.updateReviewCombat();
            this.updateAttrBg(2);
            return;
        }// end function

        private function showRefreshEffect() : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.ForgingPlayRefreshEffect));
            return;
        }// end function

        private function showReplaceEffect() : void
        {
            return;
        }// end function

        private function clearRefreshInfo() : void
        {
            var _loc_1:* = new DataProvider();
            this._currPropList.dataProvider = _loc_1;
            this._newPropList.dataProvider = _loc_1;
            this._batRefreshData = [];
            var _loc_2:int = 0;
            while (_loc_2 < this._attrBgArr.length)
            {
                
                this._attrBgArr[_loc_2].visible = true;
                _loc_2++;
            }
            return;
        }// end function

        private function clearReviewCombat() : void
        {
            this._txtEquipCombatNew.text = "";
            this._combatUpValue.text = "";
            this._upArrow.visible = false;
            if (!this._batRefreshPanel.isHide)
            {
                this._batRefreshPanel.updateAllNewCombat([]);
            }
            return;
        }// end function

        override public function clearUI() : void
        {
            var _loc_1:* = new DataProvider();
            this._currPropList.dataProvider = _loc_1;
            this._newPropList.dataProvider = _loc_1;
            this._upFee.text = "";
            this._txtEquipCombat.text = "";
            this._txtEquipCombatNew.text = "";
            this._combatUpValue.text = "";
            this._equipDescText.text = "";
            this._hotInfo.text = "";
            this._bestViewEquip.itemData = null;
            _currOperEquip.itemData = null;
            this._consumeItem1.itemData = null;
            this._consumeItem2.itemData = null;
            this._putEquipImg.visible = true;
            this._reviewText1.visible = true;
            this._reviewText2.visible = true;
            this._upArrow.visible = false;
            this._bestViewEquip.updateStrengLevel();
            _currOperEquip.updateStrengLevel();
            if (!this._batRefreshPanel.isHide)
            {
                this._batRefreshPanel.clearUI();
            }
            var _loc_2:int = 0;
            while (_loc_2 < this._attrBgArr.length)
            {
                
                this._attrBgArr[_loc_2].visible = true;
                _loc_2++;
            }
            return;
        }// end function

        private function set isReplacable(param1:Boolean) : void
        {
            if (param1)
            {
                this._replaceBtn.filters = [];
                this._replaceBtn.mouseEnabled = true;
            }
            else
            {
                this._replaceBtn.filters = [FilterConst.colorFilter2];
                this._replaceBtn.mouseEnabled = false;
            }
            return;
        }// end function

        private function get isReplacable() : Boolean
        {
            return this._replaceBtn.mouseEnabled;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            if (_isCreateChildren)
            {
                _isCreateChildren = false;
                this._refreshBtn.name = "";
                this._replaceBtn.name = "";
                this._refreshBtn.dispose(param1);
                this._replaceBtn.dispose(param1);
                this._batRefreshBtn.dispose(param1);
                this._currPropList.dispose(param1);
                this._newPropList.dispose(param1);
                _currOperEquip.dispose(param1);
                this._autoBuy.dispose(param1);
                this._batRefreshPanel.dispose(param1);
                this._equipDescText.dispose(param1);
                this._txtEquipCombat.dispose(param1);
                this._txtEquipCombatNew.dispose(param1);
                this._combatUpValue.dispose(param1);
                this._consumeItem1.dispose(param1);
                this._consumeItem2.dispose(param1);
                this._upFee.dispose(param1);
                this._bestViewEquip.dispose(param1);
                this._putEquipImg.dispose(param1);
                this._upArrow.dispose(param1);
                this._reviewText1.dispose(param1);
                this._reviewText2.dispose(param1);
                this._hotInfo.dispose();
                this._refreshBtn = null;
                this._replaceBtn = null;
                this._batRefreshBtn = null;
                this._currPropList = null;
                this._newPropList = null;
                _currOperEquip = null;
                this._autoBuy = null;
                this._batRefreshPanel = null;
                this._equipDescText = null;
                this._txtEquipCombat = null;
                this._txtEquipCombatNew = null;
                this._combatUpValue = null;
                this._consumeItem1 = null;
                this._consumeItem2 = null;
                this._upFee = null;
                this._bestViewEquip = null;
                this._putEquipImg = null;
                this._upArrow = null;
                this._reviewText1 = null;
                this._reviewText2 = null;
                this._hotInfo = null;
                this._batRefreshData.length = 0;
                this._lockNum = 0;
                this._attrBgArr.length = 0;
                this._isPropEnough = false;
                this._isLockEnough = false;
                Dispatcher.removeEventListener(EventName.SynchRefreshLock, this.syncLockState);
            }
            return;
        }// end function

    }
}
